package com.com.effectivejava.generics.examples2;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by pankaj on 6/30/15.
 */
public class UpperBoundExample {

    // <? super T> restricts the unknown type to be a specific type or super type
    // of that type.

    // <? extends T> restricts the unknown type to be a
    // specific type or sub type of that type.

    // wildcard capture: List<?>: compiler can infer the type of
    // ? during compilation when evaluating an expression.
    public static void main(String[] args) {
        List<? extends Number> list = new ArrayList<>();

        Number number = list.get(0);
        Object object = list.get(0);
        //Integer integer = list.get(0);

        List<? extends Integer> integer = new ArrayList<>();
        //integer.add(new Integer(1));
        integer.add(null);


        List<? super Integer> superInteger = new ArrayList<>();
        superInteger.add(new Integer(0));
        //superInteger.add(new Object());
        Object obj = new Object();






    }
}
